import {
  q as r,
  p as W,
  ap as z,
  X as h,
  f as D,
  H as M,
  av as f,
  aw as A,
  az as H,
  as as n,
  aG as T,
  at as i,
  ak as F,
  aH as N,
  aB as m
} from "./index-b50e6ef9.js";
function V(v) {
  const s = r([]),
    t = r(!0);
  r({}), W();
  const y = z("reload"),
    o = h({
      pageSize: 10,
      currentPage: 1,
      pageSizes: [10, 20, 30],
      total: 0,
      align: "right",
      background: !0,
      small: !1
    }),
    x = h({
      text: "正在加载第一页...",
      viewBox: "-10, -10, 50, 50",
      spinner: `
        <path class="path" d="
          M 30 15
          L 28 17
          M 25.61 25.61
          A 15 15, 0, 0, 1, 15 30
          A 15 15, 0, 1, 1, 27.99 7.5
          L 15 15
        " style="stroke-width: 4px; fill: rgba(0, 0, 0, 0)"/>
      `
    }),
    b = [
      {
        type: "selection",
        width: 55,
        align: "left",
        hide: ({ checkList: e }) => !e.includes("勾选列")
      },
      {
        label: "序号",
        type: "index",
        width: 70,
        hide: ({ checkList: e }) => !e.includes("序号列")
      },
      { label: "角色ID", prop: "role_id", minWidth: 50 },
      { label: "角色名称", prop: "role_name", minWidth: 150 },
      { label: "角色描述", prop: "role_desc", minWidth: 150 },
      { label: "操作", fixed: "right", width: 240, slot: "operation" }
    ],
    w = D(() => [
      "!h-[20px]",
      "reset-margin",
      "!text-gray-500",
      "dark:!text-white",
      "dark:hover:!text-primary"
    ]);
  async function I(e) {
    H(e);
  }
  async function S(e) {
    const l = { role_id: e.role_id },
      c = JSON.stringify(l),
      u = { value: n.enc.Base64.stringify(n.enc.Utf8.parse(c)) },
      a = await T(u);
    a.code == 200
      ? (i("删除成功", { type: "success" }), y())
      : i(a.msg, { type: "error" });
  }
  function B() {}
  function C(e) {}
  function _(e) {}
  function k(e) {}
  function J(e) {
    (x.text = `正在加载第${e}页...`),
      (t.value = !0),
      f(600).then(() => {
        t.value = !1;
      });
  }
  async function L(e) {
    var g;
    t.value = !0;
    const l = (g = F().getItem(N)) == null ? void 0 : g.role_id,
      d = JSON.stringify({ role_name: e, role: l }),
      a = { value: n.enc.Base64.stringify(n.enc.Utf8.parse(d)) },
      { data: p } = await m(a);
    (s.value = p),
      (o.total = p.total),
      setTimeout(() => {
        t.value = !1;
      }, 500);
  }
  async function R() {
    const e = await m();
    e.code === 200
      ? ((s.value = e.data),
        (o.total = e.data.total),
        setTimeout(() => {
          t.value = !1;
        }, 500))
      : i(e.msg, { type: "error" });
  }
  const U = e => {
    e && (e.resetFields(), location.reload());
  };
  return (
    M(() => {
      f().then(() => {
        const { setWatermark: e } = A(v.value.getTableDoms().tableWrapper);
        e("后台项目", {
          font: "16px Microsoft YaHei",
          globalAlpha: 0.8,
          forever: !0,
          width: 252,
          height: 80
        });
      }),
        R();
    }),
    {
      loading: t,
      columns: b,
      dataList: s,
      pagination: o,
      buttonClass: w,
      onSearch: L,
      resetForm: U,
      handleaddUser: B,
      handleUpdate: I,
      handleDelete: S,
      handleSizeChange: C,
      handleCurrentChange: _,
      handleSelectionChange: k,
      onCurrentChange: J
    }
  );
}
export { V as useRole };
